package com.gton.person.commons;

import com.gton.person.commons.excep.DIYException;
import com.gton.person.commons.myenum.ExcptionEnum;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MaxUploadSizeExceededException;

import javax.servlet.http.HttpServletResponse;

/**
 * @program: PersonalDesign
 * @description: 统一异常处理
 * @author: GuoTong
 * @create: 2020-11-12 17:08
 **/
@ControllerAdvice
public class GlobalExceptionAdvice {

    /**其他异常*/
    @ExceptionHandler(Exception.class)
    public ResultAdvice uploadException(Exception e){
        return ResultAdvice.otherError(ExcptionEnum.INTERNAL_SERVER_ERROR);
    }
    /**
     * 处理自定义异常
     */
    @ExceptionHandler(value = DIYException.class)
    public ResultAdvice bizExceptionHandler(DIYException e) {
        return ResultAdvice.diyExcption(e);
    }
}
